<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <title><%= title %></title>


    <!-- Bootstrap core CSS -->
    <link href="../../css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="../../css/starter-template.css" rel="stylesheet">

    <link href="../../css/theme.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="../../js/html5shiv.js"></script>
    <script src="../../js/respond.min.js"></script>
    <![endif]-->

    <script type="text/javascript" src="../../js/jquery-1.7.1.min.js"></script>
    <script src="../../js/bootstrap.min.js"></script>

    <!--CodeMirror-->
    <link href="../../css/codemirror.css" rel="stylesheet">
    <script src="../../js/codemirror.min.js"></script>
    <script src="../../js/sql.js"></script>

    <script type="text/javascript">

        $(function () {

            $("#Category").val("<%=row.Category%>");

            $("#Key").on("change", function () {
                $.get("/configs/checkKey/", {Key: $("#Key").val()}, function (data) {
                    if(data.ok) {
                        $("#btnSave").removeAttr("disabled");
                        $("#lblMessage").hide();
                    }
                    else {
                        $("#btnSave").attr("disabled", "disabled");
                        $("#lblMessage").show();
                        $("#lblMessage").html("键重复，请重新输入！");
                    }

                });
            });
            <% if (row.Id == 0){%>
            $("#btnSave").attr("disabled","disabled");
            $("#btnDelete").attr("disabled","disabled");
            <%}%>

            $("#btnDelete").on("click", function () {
                $.post("/configs/del/<%=row.Id%>", {}, function (data) {
                    if(data.ok) {
                        alert("删除完成，点击跳转到列表页面...");
                        window.location = "/configs/";
                    }
                }, "JSON");
            });
        });

    </script>
</head>
<body>

<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="/">互动平台报表发布系统</a>
        </div>
        <div class="collapse navbar-collapse">
            <ul class="nav navbar-nav">
                <li runat="server" id="liReportList"><a href="/reports/">报表列表</a></li>
                <li runat="server" id="liConfigList" class="active"><a href="/configs/">配置列表</a></li>
                <li runat="server" id="liReportCreate"><a href="/report/edit/0">新建</a></li>
            </ul>
        </div>
        <!--/.nav-collapse -->
    </div>
</div>

<div class="container">

    <div class="starter-template">
        <form id="form1" action="/configs/edit/<%=row.Id%>" method="post">
            <div id="lblMessage" class="alert alert-danger" style="display: none;" role="alert"></div>
            <table style="width: 100%">
                <tbody>
                <tr>
                    <td style="text-align: right;">键：</td>
                    <td>
                        <input type="text" id="Key" name="Key" <% if(row.Id != 0){%> readonly="readonly" <%}%> style="width:100%" value="<%=row.Key%>" /></td>
                </tr>
                <tr>
                    <td style="text-align: right;">分类：</td>
                    <td>
                        <select id="Category" name="Category">
                            <option value="System">系统配置</option>
                            <option value="User">用户配置</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right;">描述：</td>
                    <td>
                        <input type="text" id="Comment" name="Comment" style="width:100%" value="<%=row.Comment%>" /></td>
                </tr>
                <tr>
                    <td style="text-align: right;">值：</td>
                    <td>
                        <input type="text" id="Value" name="Value" style="width:100%" value="<%=row.Value%>" /></td>
                </tr>
                <tr>
                    <td style="width: 100px; text-align: right;"></td>
                    <td>
                        <input type="hidden" id="hidId" value="<%=row.Id%>">
                        <input type="submit" id="btnSave" class="btn btn-primary" style="width: 70%; float: left;" value="保存" />
                        <input type="btnDel" id="btnDelete" class="btn btn-danger" style="width: 30%; float: right;" value="删除" /></td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>

</div>
<!-- /.container -->
</body>
</html>
